鐵人賽後功力大增,並沒有因為完成鐵人賽就中斷學習,目前還不斷把pipeline增加可攜性,以及更企業級的架構。
之前完成CI流程後,接著要處理deploy時,遇到image還需要用usb攜帶到設備上版,能否使用harbor這類的container registry,且增加自動化的安全機制,就是接下來的議題。
grype沒有api,為了讓整個pipeline尾巴改成放到registry,後續再給deploy流程去跑,所以移除grype,改用NeuVector,本來包成tar的流程,也改成push上harbor。
先看一下強大的NeuVector的功能介紹吧!!!
https://www.cnblogs.com/rancherlabs/p/16111452.html
記得image命名原則:
harbor server name/project name/images name:version
參考:
https://goharbor.io/docs/2.9.0/working-with-projects/working-with-images/pulling-pushing-images/
insecure registry的設定參考:
https://docs.docker.com/registry/insecure/
Harbor以前是使用Clair,現在是用Trivy
https://github.com/quay/clair
預設的掃描器是Trivy
https://goharbor.io/docs/2.9.0/administration/vulnerability-scanning/
如果要預設使用安全掃描器Trivy,安裝時可以下以下指令:
sudo ./install.sh --with-trivy
參考:
https://goharbor.io/docs/2.9.0/install-config/run-installer-script/
Trivy介紹:
https://aquasecurity.github.io/trivy/v0.45/
https://github.com/neuvector/neuvector
後來選擇這個,添加一下service寫法,以及network指定ip,就可以正常運作(NO privileged mode):
https://open-docs.neuvector.com/deploying/docker#deploy-allinone-no-privileged-mode-with-docker-compose
version: "3"
services:
allinone:
pid: host
image: neuvector/allinone
container_name: neuvector.allinone
cap_add:
- SYS_ADMIN
- NET_ADMIN
- SYS_PTRACE
- IPC_LOCK
security_opt:
- apparmor=unconfined
- seccomp=unconfined
- label=disable
environment:
- CLUSTER_JOIN_ADDR=172.18.0.200
- NV_PLATFORM_INFO=platform=Docker
ports:
- 18300:18300
- 18301:18301
- 18400:18400
- 18401:18401
- 18301:18301/udp
- 8443:8443
volumes:
- /lib/modules:/lib/modules:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc:/host/proc:ro
- /sys/fs/cgroup:/host/cgroup:ro
- /var/neuvector:/var/neuvector
networks:
ap_net:
ipv4_address: 172.18.0.200
Scanner:
image: neuvector/scanner:latest
container_name: scanner
environment:
- CLUSTER_JOIN_ADDR=172.18.0.200
ports:
- 18402:18402
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- ap_net
networks:
ap_net:
external: true
預設帳密:admin/admin
https://github.com/neuvector/neuvector-operator/blob/master/docs/NeuVectorDeployKubernetes.md
相當完整的資安平台呀...
提醒一下:
https://russ_liu.gitlab.io/blog/2022/02/08/Enable-Gitlab-Container-Registry/
gitlab的環境變數微調一下,就可以啟用了
registry_external_url 'http://registry.docker.localhost'
# 關閉container registry
#gitlab_rails['gitlab_default_projects_features_container_registry'] = false
#gitlab_rails['registry_enabled'] = false
#registry['enable'] = false
#registry_nginx['enable'] = false
記得要用PAT喔
再來我們來push上去吧
docker login registry.docker.localhost
docker tag xxx:1121012 registry.docker.localhost/root/xxx:1121012
docker push registry.docker.localhost/root/xxx:1121012
https://goharbor.io/docs/2.9.0/administration/vulnerability-scanning/pluggable-scanners/
注意,neuvector要跟gitlab整合的話,會要求要用https
因為考量gitlab container registry蠻陽春,就中止了
https://www.cnblogs.com/rancherlabs/p/16111452.html
這篇看起來是可以把harbor使用docker registry的連結方式整合
但我這邊會遇到問題:harbor的ip是什麼?
要回答這個問題,要有兩個步驟:
我們看到harbor有對外的是這個container
看到它的ip了
我們知道我們設定的對外port是8089,但真實的port要看nginx的設定
依照上述的方式取得ip:port,就可以放進去neuvector
設定成功~~~
目前還需要找方法...
本次曾經作過2.7更新到2.9,本來移植舊版的common資料夾跟harbor.yml,結果會噴錯誤
所以,/data可以共用外,harbor.yml也不能共用